// 引入变量
@import './variables';
@import './high-resolution';

// 全局样式
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial,
    'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
    'Noto Color Emoji', 'Microsoft YaHei', '微软雅黑';
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

// 滚动条样式
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
  transition: all 0.3s;

  &:hover {
    background: #999;
  }
}

// 清除浮动
.clearfix::after {
  content: '';
  display: table;
  clear: both;
}

// 文本省略
.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-ellipsis-2 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

// 动画
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

// 淡入动画
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

// 滑动动画
.slide-enter-active,
.slide-leave-active {
  transition: all 0.3s ease;
}

.slide-enter-from {
  transform: translateX(-20px);
  opacity: 0;
}

.slide-leave-to {
  transform: translateX(20px);
  opacity: 0;
}

// 缩放动画
.zoom-enter-active,
.zoom-leave-active {
  transition: all 0.3s ease;
}

.zoom-enter-from,
.zoom-leave-to {
  transform: scale(0.95);
  opacity: 0;
}

// 工具类
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-1 {
  flex: 1;
}

// 间距
.mt-10 {
  margin-top: 10px;
}

.mt-20 {
  margin-top: 20px;
}

.mb-10 {
  margin-bottom: 10px;
}

.mb-20 {
  margin-bottom: 20px;
}

.ml-10 {
  margin-left: 10px;
}

.mr-10 {
  margin-right: 10px;
}

.pt-10 {
  padding-top: 10px;
}

.pb-10 {
  padding-bottom: 10px;
}

.pl-10 {
  padding-left: 10px;
}

.pr-10 {
  padding-right: 10px;
}

// 颜色
.text-primary {
  color: #e4393c;
}

.text-success {
  color: #52c41a;
}

.text-warning {
  color: #faad14;
}

.text-danger {
  color: #ff4d4f;
}

.text-info {
  color: #1890ff;
}

.text-gray {
  color: #999;
}

// 背景色
.bg-primary {
  background-color: #e4393c;
}

.bg-success {
  background-color: #52c41a;
}

.bg-warning {
  background-color: #faad14;
}

.bg-danger {
  background-color: #ff4d4f;
}

.bg-info {
  background-color: #1890ff;
}

.bg-white {
  background-color: #fff;
}

.bg-gray {
  background-color: #f5f5f5;
}

// 卡片
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;

  &:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
    border-color: #e4393c;
  }
}

// 按钮
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;

  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
}

.btn-primary {
  background: #e4393c;
  color: #fff;
  border-color: #e4393c;

  &:hover:not(:disabled) {
    background: darken(#e4393c, 10%);
    border-color: darken(#e4393c, 10%);
  }
}

.btn-outline-primary {
  background: transparent;
  color: #e4393c;
  border-color: #e4393c;

  &:hover:not(:disabled) {
    background: #e4393c;
    color: #fff;
  }
}

.btn-success {
  background: #52c41a;
  color: #fff;
  border-color: #52c41a;

  &:hover:not(:disabled) {
    background: darken(#52c41a, 10%);
    border-color: darken(#52c41a, 10%);
  }
}

// 加载状态
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top-color: #e4393c;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

// 响应式
@media (max-width: 1200px) {
  .main-container {
    max-width: 100%;
    padding: 15px;
  }
}

@media (max-width: 768px) {
  body {
    font-size: 13px;
  }

  .main-container {
    padding: 10px;
  }
}

// 4K和更高分辨率屏幕适配 - 使用CSS zoom属性
@include desktop-4k {
  // 使用CSS zoom属性进行等比缩放
  html {
    zoom: 2;
    width: 100%;
  }
  
  body {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  
  // 确保定位元素正常工作
  .main-nav {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
  }
  
  .floating-menu {
    position: fixed !important;
    right: 20px !important;
    bottom: 20px !important;
    z-index: 9999 !important;
  }
  
  .app-header {
    position: relative !important;
    z-index: 1001 !important;
  }
  
  // 商品相关元素防转行
  .product-card,
  .product-item,
  .hot-products {
    .product-title,
    .product-name,
    .product-subtitle,
    .product-description,
    .price-row,
    .product-price,
    .product-stats {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

@include desktop-5k {
  // 使用CSS zoom属性进行等比缩放
  html {
    zoom: 2.5;
    width: 100%;
  }
  
  body {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  
  // 确保定位元素正常工作
  .main-nav {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
  }
  
  .floating-menu {
    position: fixed !important;
    right: 20px !important;
    bottom: 20px !important;
    z-index: 9999 !important;
  }
  
  .app-header {
    position: relative !important;
    z-index: 1001 !important;
  }
  
  // 商品相关元素防转行
  .product-card,
  .product-item,
  .hot-products {
    .product-title,
    .product-name,
    .product-subtitle,
    .product-description,
    .price-row,
    .product-price,
    .product-stats {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

// Element Plus 覆盖样式
.el-button {
  font-family: inherit;
}

.el-input__wrapper {
  font-family: inherit;
}

// 图片懒加载占位
img[lazy='loading'] {
  background: #f5f5f5;
}

img[lazy='error'] {
  background: #f5f5f5;
}

// 通用过渡
.page-enter-active,
.page-leave-active {
  transition: opacity 0.3s, transform 0.3s;
}

.page-enter-from {
  opacity: 0;
  transform: translateY(10px);
}

.page-leave-to {
  opacity: 0;
  transform: translateY(-10px);
}
